package util

import (
	"path"
	"path/filepath"
	"runtime"
	"strings"
)

func IsAPI(workspace, path, goModPath string) bool {
	apiPath := GetAPIPath()
	return strings.HasPrefix(filepath.FromSlash(path), apiPath) || strings.HasPrefix(filepath.FromSlash(path), filepath.Join(workspace, goModPath))
}

func GetAPIPath() string {
	return filepath.FromSlash(path.Clean(runtime.GOROOT() + "/src"))
}
